package edu.bbu.commonproject.desktop.gui.view.swing.file.lister.components;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JPanel;

import edu.bbu.commonproject.desktop.gui.view.swing.utils.Design;

/**
 * The parent directori in the file lister.
 */
public class LParentDirectory extends JPanel
{
	/** Boolean value of the mouse if it is over the component. */
	private boolean mouseOver = false;
	
	/**
	 * The constructor.
	 * @param directoryName the name of directory.
	 * @param fileLister the file lister where the directory belong.
	 */
	public LParentDirectory()
	{		
		setListener();
		
		this.setBackground(Color.WHITE);
		this.setPreferredSize(new Dimension(100,100));
	}
	
	/**
	 * Setting up the mouse listeners.
	 */
	private void setListener()
	{		
		this.addMouseListener(new MouseAdapter()
		{
			public void mouseEntered(MouseEvent e)
			{
				mouseOver = true;
				repaint();
			}
			
			public void mouseExited(MouseEvent e)
			{
				mouseOver = false;
				repaint();
			}
		});
	}
	
	/**
	 * The overrided painComponent.
	 */
	protected void paintComponent(Graphics g)
	{
		super.paintComponent(g);	
		
		if (mouseOver)
		{
			g.drawImage(Design.FILELIST_MOUSEOVER, 0, 0, null);
		}
		
		g.drawImage(Design.FILELIST_GOBACK, 22, 22, null);
	}
}
